#include<iostream>
#include<iomanip>
using namespace std;
class Time
{
	int hour, minute, second;
public:
	Time(int h, int m,int s=0);
	Time(int s );
	int SecCalc()
	{
		return (hour * 60 + minute) * 60 + second;
	}
	void SetTime(int h , int m, int s );
	void print_12();
	void print_24();
	Time ADD(Time& t2);
	Time Sub(Time& t2);

};
Time::Time(int h,int m,int s)
{
	hour = h;
	minute = m;
	second = 0;
}
Time::Time(int s)
{
	hour = s / 3600;
	minute = (s - hour * 3600) / 60;
	second = s - minute * 60 - hour * 3600;
}
void Time::SetTime(int h, int m, int s)
{
	hour = h;
	minute = m;
	second = s;
}
void Time::print_12()
{
	if (hour > 12)
	{
		int h = hour - 12;
		if (minute < 0)
		{
			h--;
			minute += 60;
		}
		printf("%02d:%02d:%02d PM", h, minute, second);
	}
	else
	{	
		printf("%02d:%02d:%02d", hour, minute, second);
	}
}
void Time::print_24()
{
	if (minute < 0)
	{
		hour--;
		minute += 60;
	}
	printf("%02d:%02d:%02d", hour, minute, second);
}
 Time Time::Sub(Time& t2)
{
	 Time t(0);
	 if (hour > t2.hour)
	 {
		t. hour = hour - t2.hour;
		 t.minute = minute - t2.minute;
		 t.second = second - t2.second;
	 }
	 else
	 {
		 t.hour =  t2.hour-hour;
		 t.minute = t2.minute-minute;
		 t.second = t2.second-second;
	 }
	 return t;
 }
 Time Time::ADD(Time& t2)
 {
	 Time t(0);
	 t.hour = hour + t2.hour;
	 t.minute = minute + t2.minute;
	 t.second = second + t2.second;
	 return t;
 }
int main()
{
	Time t1(2, 34), t2(0), t3(3723);
	t2.SetTime(13, 23, 34);
	cout << "t2:"  ;
	t2.print_12();
	cout << endl << "t2:";
	t2.print_24();
	cout << "\nt1+t2:";
	t1.ADD(t2).print_24();
	cout << "\nt2-t1:";
	t1.Sub(t2).print_24();
	cout << endl << "t3:";
	t3.print_24();
	return 0;
}